package com.yulongtian.offers.day202209.day20220905;

/**
 * https://leetcode.cn/problems/xuan-zhuan-shu-zu-de-zui-xiao-shu-zi-lcof/
 * @author YulongTian
 * @date 2022/9/5 - 13:33
 */
public class Test02 {
    public static void main(String[] args) {
        //int[] numbers={7,10,12,15,1,4,5,6};
        //int[] numbers = {1, 3, 5};
        int[] numbers = {3,1,1};
        //int[] numbers = {1,2,1};
        System.out.println(minArray(numbers));
    }

    public static int minArray(int[] numbers) {
        int low = 0;
        int high = numbers.length - 1;
        while (low < high) {
            int pivot = low + (high - low) / 2;
            if (numbers[pivot] < numbers[high]) {
                high = pivot;
            } else if (numbers[pivot] > numbers[high]) {
                low = pivot + 1;
            } else {
                high -= 1;
            }
        }
        return numbers[low];
    }

}
